<?php
class Up_model extends CI_Model {

    public function __construct()
    {
        $this->load->database();
    }
    public function save($data)
    {

    	if($data['id']==0){
    		$this->db->insert('ims_enread_material', $data);	
    	}else{
    		$this->db->where('id',$data['id']);
    		$this->db->update('ims_enread_material', $data);
    	}
        $re = $this->db->where('weid',$data['weid']);
        $re2 = $this->db->where('us_id',$data['us_id']);
        $this->db->from('ims_enread_user');
        $query = $this->db->count_all_results();
        //var_dump($query);
        if($query==0){
            $wei['weid'] = $data['weid'];
            $wei['us_id'] = $data['us_id'];
            $this->db->insert('ims_enread_user', $wei);
        }
       // var_dump($query["row_data"]);
    }
}